<?php 
class Nadeb_Form_Captcha_File
{
	public function get($_bg,$_font)
	{
		$captcha          = new Zend_Session_Namespace();
		$captcha->captcha = rand(100000,999999); 
		$textoCaptcha     = $captcha->captcha . " ";
		
 		$imagemCaptcha = imagecreatefrompng( $_SERVER['DOCUMENT_ROOT'] . ROOT . '/public/captcha/bg/' . $_bg );
		$fonteCaptcha  = imageloadfont     ( $_SERVER['DOCUMENT_ROOT'] . ROOT . '/public/captcha/font/' . $_font );
		$corCaptcha    = imagecolorallocate($imagemCaptcha,150,150,150);
		$name         = md5(uniqid(''));

		$init = 10;
		for( $i=0;$i<strlen($textoCaptcha);$i++ )
		{
			imagestring($imagemCaptcha,$fonteCaptcha,$init,rand(1,20),$textoCaptcha[$i],$corCaptcha);
			$init = $init + 18;
		}
		imagefilter($imagemCaptcha, IMG_FILTER_GAUSSIAN_BLUR);
		imagefilter($imagemCaptcha, IMG_FILTER_GAUSSIAN_BLUR);
		imagefilter($imagemCaptcha, IMG_FILTER_GAUSSIAN_BLUR);
		imagepng($imagemCaptcha, $_SERVER['DOCUMENT_ROOT'] . ROOT . '/public/captcha/temps/' . $name . '.png' );
		imagedestroy($imagemCaptcha);
		
		return $name;
	}
}